<!--
 * @Author: ujjldn ujjldn0515@163.com
 * @Date: 2025-06-15 18:52:53
 * @LastEditors: ujjldn ujjldn0515@163.com
 * @LastEditTime: 2025-08-02 19:02:14
 * @FilePath: \g-table\test\test.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>g-drawer 测试实例</title>
<script src="../node_modules/vue/dist/vue.global.prod.js"></script>
<link rel="stylesheet" href="../node_modules/element-plus/dist/index.css">
<script src="../node_modules/element-plus/dist/index.full.min.js"></script>
<!-- <script src="../node_modules/axios/dist/axios.min.js"></script> -->
<script src="../dist/g-drawer.umd.js"></script>
<link rel="stylesheet" href="../dist/g-drawer.css" />
</head>
<body>
<div id="app">
	<div>
		<el-input
			placeholder="请输入内容"
			v-model="inputText"
		/>
	</div>
 <div>

  <el-button
    type="primary"
    @click="openDrawer"
  >
    打开抽屉
  </el-button>
 </div> 
  

  <character-drawer
    ref="CharacterDrawerRef"
    @character-selected="onCharacterSelected"
  />
</div>

<script setup>
    const { ref, reactive, onMounted, nextTick, createApp } = Vue;
    const { CharacterDrawer } = window.GDrawer; 
    const { ElMessage } = ElementPlus;    
    
    const app = createApp({
      data() {
        return {
            inputText:'',
        };
      },
      methods: {
        onCharacterSelected(char){
            ElMessage.success(`你选择了${char}`)
        },
        openDrawer(){
            console.log('CharacterDrawerRef:', this.$refs.CharacterDrawerRef);
            if (this.$refs.CharacterDrawerRef) {
                nextTick(() => {
                    console.log('Drawer properties:', Object.getOwnPropertyNames(this.$refs.CharacterDrawerRef));
                    if (typeof this.$refs.CharacterDrawerRef.openDrawer === 'function') {
                        this.$refs.CharacterDrawerRef.openDrawer();
                    } else {
                        ElMessage.error('Drawer openDrawer 方法不可用');
                    }
                });
            } else {
                ElMessage.error('Drawer 组件引用不存在');
            }
        },
      }
    });

    // 确保两个组件都存在再注册
    app.use(ElementPlus);
    app.component('character-drawer', CharacterDrawer);
    app.mount('#app');
</script>
</body>
</html>